package com.bawei.day0129.view.activity;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.bawei.day0129.R;
import com.bawei.day0129.view.fragment.FivewFragment;
import com.bawei.day0129.view.fragment.FourFragment;
import com.bawei.day0129.view.fragment.OneFragment;
import com.bawei.day0129.view.fragment.ThreeFragment;
import com.bawei.day0129.view.fragment.TwoFragment;

import java.util.ArrayList;

public class CommeActivity extends AppCompatActivity {

    private ViewPager vg1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_comme);
        initView();
        ArrayList<Fragment> list = new ArrayList<>();
        list.add(new OneFragment());
        list.add(new TwoFragment());
        list.add(new ThreeFragment());
        list.add(new FourFragment());
        list.add(new FivewFragment());
        vg1.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @NonNull
            @Override
            public Fragment getItem(int position) {
                return list.get(position);
            }

            @Override
            public int getCount() {
                return list.size();
            }
        });
    }

    private void initView() {
        vg1 = (ViewPager) findViewById(R.id.vg1);
    }
}